Commit | Line | Data |
---|---|---|
ee49ff3d CE |
1 | // arcade controller thing |
2 | // Copyright (c) 2017 Clinton Ebadi <clinton@unknownlamer.org> | |
3 | // GPLv3 or (at your option) any later version | |
4 | // .. insert license text here ... | |
5 | ||
6 | use <obiscad/bcube.scad> | |
c3a57278 CE |
7 | use <obiscad/attach.scad> |
8 | ||
9 | // PREVIEW | |
10 | union () { | |
11 | rotate ([-10, 0, 0]) translate ([0, 0, box_h+20]) panel (); | |
12 | case (); | |
13 | } | |
14 | ||
15 | ||
16 | // CONFIGURATION | |
17 | ||
18 | panel_w = 250; | |
19 | panel_h = 120; | |
20 | ||
21 | box_h = 80; // fixme: box_d. | |
22 | box_wall = 2; | |
23 | base_h = 5; //fixme: thickness? | |
24 | ||
25 | // bcube parameters, clean up | |
26 | cr = box_wall*2; | |
27 | cres = 0; | |
ee49ff3d CE |
28 | |
29 | $button_d = 28; | |
c3a57278 CE |
30 | js_width = 85; |
31 | js_height = 40; | |
32 | ||
33 | // PANEL COMPONENTS | |
ee49ff3d CE |
34 | |
35 | module button (bezel = $button_d+4) { | |
36 | circle (d=$button_d); | |
37 | %circle(d=bezel); | |
38 | } | |
39 | ||
ee49ff3d CE |
40 | |
41 | module joystick () { | |
42 | bolt_d = 8; | |
43 | center_hole_d = 24; | |
44 | ||
c3a57278 | 45 | for (x = [-js_width/2, js_width/2], y = [-js_height/2, js_height/2]) { |
ee49ff3d CE |
46 | translate ([x, y, 0]) circle (d=bolt_d); // need slot instead |
47 | } | |
c3a57278 CE |
48 | circle (d=center_hole_d); |
49 | ||
50 | %square ([js_width, js_height], center=true); // not right... | |
ee49ff3d CE |
51 | } |
52 | ||
ee49ff3d | 53 | |
c3a57278 | 54 | // CASE |
ee49ff3d | 55 | |
c3a57278 CE |
56 | module case_base (h=base_h) { |
57 | bcube([panel_w, panel_h, h], cr, cres); | |
ee49ff3d CE |
58 | } |
59 | ||
c3a57278 | 60 | module case_walls () { |
ee49ff3d | 61 | difference() { |
ee49ff3d CE |
62 | bcube([panel_w, panel_h, box_h-base_h], cr, cres); |
63 | bcube([panel_w-box_wall, panel_h-box_wall, box_h], cr, cres); | |
64 | } | |
65 | } | |
66 | ||
c3a57278 CE |
67 | module case () { |
68 | case_base (); | |
69 | translate ([0, 0, (box_h)/2]) case_walls (); | |
ee49ff3d CE |
70 | } |
71 | ||
72 | ||
c3a57278 | 73 | // PANEL |
ee49ff3d CE |
74 | |
75 | module panel () { | |
76 | difference () { | |
c3a57278 CE |
77 | case_base (); |
78 | linear_extrude (base_h*2,center=true) panel_layout (); | |
ee49ff3d CE |
79 | } |
80 | } | |
81 | ||
c3a57278 CE |
82 | module panel_attach (position, angle=0) { |
83 | x = position[0]; | |
84 | y = position[1]; | |
85 | c1 = [ [x, y, base_h/2], [0,0,1], angle ]; //[0, 0, h]; | |
86 | a1 = [ [0,0, 0], [0,0,0], 0 ]; | |
87 | // connector (c1); | |
88 | attach (c1, a1) children (); | |
89 | } | |
ee49ff3d | 90 | |
c3a57278 | 91 | // panel layout inspired by the Neo Geo layout |
ee49ff3d | 92 | module panel_layout () { |
c3a57278 CE |
93 | translate ([-panel_w/2 + 40, 0, 0]) { |
94 | panel_attach ([0, 0], 90) joystick (); | |
95 | ||
96 | // p1, coin (floating off in the distance...) | |
97 | union () { | |
98 | $button_d=18; | |
99 | for (x = [0, $button_d+10]) { | |
100 | panel_attach ([x, 90]) button (); | |
101 | panel_attach ([x, 90]) button (); | |
102 | } | |
103 | } | |
ee49ff3d | 104 | |
c3a57278 CE |
105 | // a, b, c, d |
106 | union () { | |
107 | buttons_offset = 60; | |
108 | panel_attach ([buttons_offset, 0]) button (); | |
109 | for (i = [ 1 : 3 ]) { | |
110 | panel_attach ([i*($button_d+10)+buttons_offset-5, 30]) button (); | |
111 | } | |
ee49ff3d CE |
112 | } |
113 | } | |
114 | } |